package com.aegis.manage.controller.gateway;

import com.aegis.manage.api.request.AddOrUpdateGatewayRouteRequest;
import com.aegis.manage.api.vo.RouteVO;
import com.aegis.manage.service.gateway.GatewayConfigService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author wuweixin
 * 
 * @Version 1.0
 * @Descritube
 */
@RestController
@RequestMapping("/gateway/config")
@Api(tags = "网关-网关配置")
public class GatewayConfigController {

    @Autowired
    private GatewayConfigService gatewayConfigService;

    @GetMapping("/route/list")
    public List<RouteVO> getGatewayRoutes() {
        return gatewayConfigService.queryRouteList();
    }

    @PostMapping("/route/add")
    public void addRoute(@RequestBody @Validated AddOrUpdateGatewayRouteRequest request) {
        gatewayConfigService.addRoute(request);
    }

    @PutMapping("/route/update")
    public void updateRoute(@RequestBody @Validated AddOrUpdateGatewayRouteRequest request) {
        gatewayConfigService.updateRoute(request);
    }

    @DeleteMapping("/route/del")
    public void delRoute(@RequestParam String id) {
        gatewayConfigService.delRoute(id);
    }

}
